package com.my.createtype.prototype;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test {

	public static void main(String[] args) throws CloneNotSupportedException {
		Prototype p = new Prototype();
		p.setName("tom");
		List<String> list = new ArrayList<String>();
		list.add("a");
		list.add("b");
		list.add("c");
		list.add("d");
		p.setChildren(list);
		
		String[] sons = {"1", "2", "3"};
		p.setSons(sons);
		
		System.out.println(p);
		
		Prototype p1 = (Prototype) p.clone();
		p1.setName("jerry");
		/*List<String> list1 = new ArrayList<String>();
		list1.add("e");
		list1.add("f");
		list1.add("g");
		list1.add("h");
		p1.setChildren(list1);*/
		
		p1.getChildren().set(0, "shit");
		
		System.out.println(p + "-" + p1);
		
		// 数组可以深度复制
		String[] s1 = {"1", "2", "3"};
		String[] s2 = s1.clone();
		s2[0] = "4";
		System.out.println(Arrays.asList(s1) + "=" + Arrays.asList(s2));

	}

}
